<template>
	<view class="model" v-if="visible" @click="$emit('closeModel')">
		<div class="cont" @click.stop>
			<input type="text" v-model="modelForm.name" placeholder="请输入名称"/>
			<input type="text" v-model="modelForm.cont" placeholder="请输入内容"/>
			<view class="submit" @click="modelSubmit">确定</view>
		</div>
	</view>
</template>

<script>
	export default {
		name:"h-addmodel",
		props:['visible'],
		data() {
			return {
				modelForm:{name:'',cont:''},
			};
		},
		mounted(){
			
		},
		methods:{
			modelSubmit(){
				let { name , cont } = this.modelForm;
				if(!name){this.$u.toast('请输入名称');return}
				if(!cont){this.$u.toast('请输入内容');return}
				
				let modelFrom = JSON.parse(JSON.stringify(this.modelForm))
				this.$emit('modelDb',modelFrom)
				this.modelForm.name = this.modelForm.cont = ''
			},
		}
		
	}
</script>

<style lang="scss">
	.model{
		position: fixed;
		top: 0;left: 0;right: 0;bottom: 0;
		background-color: rgba(0,0,0,.5);
		display: flex;
		align-items: center;
		justify-content: center;
		width: 100%;
		border-radius: 0px;
		.cont{
			background-color: #FFFFFF;
			border-radius: 10rpx;
			padding: 20rpx;
			width: 80%;
			input{
				border: 1px solid rgba(0,0,0,.2);
				height: 100rpx;
				margin-bottom: 20rpx;
				padding-left: 50rpx;
				border-radius: 20rpx;
			}
			.submit{
				width: 100%;
				margin: 10px auto 0;
			}
		}
	}
</style>
